<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    /* 第一步：定义动画（方式一） */
    @keyframes width-animation {
      from {
        width: 100px;
      }

      to {
        width: 500px;
      }
    }

    /* 第一步：定义动画（方式二） */
    @keyframes height-animation {
      0% {
        height: 100px;
      }

      50% {
        height: 300px;
      }

      100% {
        height: 500px;
      }
    }

    div {
      background-color: #17f;
      /* 第二步：使用动画 */
      animation-name: width-animation, height-animation;
      animation-duration: 3s;
      animation-timing-function: linear;
      animation-iteration-count: infinite;
      animation-direction: alternate;
    }
  </style>
</head>

<body>
  <div></div>
</body>

</html>